[][src]Crate fallible_collections

impl Fallible collections on allocation errors, quite as describe in RFC 2116 This was used in the turbofish OS hobby project to mitigate the the lack of faillible allocation in rust.

The Try* types in this module are thin wrappers around the stdlib types to add support for fallible allocation. The API differences from the stdlib types ensure that all operations which allocate return a Result. For the most part, this simply means adding a Result return value to functions which return nothing or a non-Result value. However, these types implement some traits whose API cannot communicate failure, but which do require allocation, so it is important that these wrapper types do not implement these traits.

Specifically, these types must not implement any of the following traits:

  • Clone
  • Extend
  • From
  • FromIterator

This list may not be exhaustive. Exercise caution when implementing any new traits to ensure they won't potentially allocate in a way that can't return a Result to indicate allocation failure.

Re-exports

pub use boxed::*;
pub use vec::*;
pub use rc::*;
pub use arc::*;
pub use hashmap::*;

Modules

arc

Implement a Fallible Arc

boxed

Implement Fallible Box

format

A try_format! macro replacing format!

hashmap

Implement Fallible HashMap

rc

Implement a Fallible Rc

try_clone

this module implements try clone for primitive rust types

vec

Implement Fallible Vec

Macros

tryformat

Take a max capacity a try allocating a string with it.

Enums

TryReserveError

The error type for try_reserve methods.

Traits

TryClone

trait for trying to clone an elem, return an error instead of panic if allocation failed